<include file="public@header"/>
<body>
<div class="wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:url('Stuff/index')}">材料库</a></li>
        <li class="active"><a href="{:url('Stuff/add')}">新增材料</a></li>
    </ul>
    <form class="form-horizontal js-ajax-form" action="{:url('Stuff/add_post')}" method="post"
          enctype="multipart/form-data">
        <fieldset>
            <div class="control-group">
                <label class="control-label">材料名称</label>
                <div class="controls">
                    <input type="text" name="stuff_name" class="form-control" required/>
                    <span class="form-required">*</span>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">类型</label>
                <div class="controls">
                    <select name="cate_id" class="form-control" required>
                        <volist name="cate_name" id="vo">
                            <option value="{$vo.id}">{$vo.cate_name}</option>
                        </volist>
                    </select>
                    <span class="form-required">*</span>
                </div>
            </div>
            <div class="control-group normal">
                <label class="control-label">价格</label>
                <div class="controls">
                    <input type="text" name="stuff_money" placeholder="请输入价格" class="form-control" required
                           onInput="clearNoNum(this)"/>
                    <span class="form-required">*</span>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">单位</label>
                <div class="controls">
                    <select name="stuff_unit" class="form-control" required>
                        <option value="立方价">立方价</option>
                        <option value="平方价">平方价</option>
                        <option value="吨">吨</option>
                        <option value="公斤">公斤</option>
                    </select>
                    <span class="form-required">*</span>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">排序</label>
                <div class="controls">
                    <input name="list_order" type='text' size='3' value='255' class="form-control" required>
                    <span class="form-required">*</span>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">{:lang('ROCK_IMG')}</label>
                <div class="controls">
                    <input type="hidden" name="stuff_image" id="thumb">
                    <a href="javascript:uploadOneImage('图片上传','#thumb');">
                        <h5 class="btn btn-primary">上传</h5>
                        <img src="" id="thumb-preview"
                             width="135" style="cursor: hand"/>
                    </a>
                    <input type="button" class="btn btn-sm"
                           onclick="$('#thumb-preview').attr('src','');$('#thumb').val('');return false;"
                           value="取消图片">
                </div>
            </div>
            <!--<div class="control-group">
                <label class="control-label">{:lang('STATUS')}</label>
                <div class="controls">
                    <input type="radio" name="status" value="1" checked>启用
                    <input type="radio" name="status" value="2"> 关闭
                </div>
            </div>-->
        </fieldset>
        <div class="form-actions">
            <button type="submit" class="btn btn-primary js-ajax-submit">{:lang('ADD')}</button>
            <a class="btn btn-default" href="javascript:history.back(-1);">{:lang('BACK')}</a>
        </div>
    </form>
</div>
<script type="text/javascript" src="__STATIC__/js/admin.js?v={:time()}"></script>
<script type="text/javascript" src="__STATIC__/js/layer/layer.js"></script>
<script type="text/javascript">


    function clearNoNum(obj) {
        //先把非数字的都替换掉，除了数字和.
        obj.value = obj.value.replace(/[^\d.]/g, "");
        //必须保证第一个为数字而不是.
        obj.value = obj.value.replace(/^\./g, "");
        //保证只有出现一个.而没有多个.
        obj.value = obj.value.replace(/\.{2,}/g, ".");
        //保证.只出现一次，而不能出现两次以上
        obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
        //保证 数字整数位不大于8位
        if (100000000 <= parseFloat(obj.value))
            obj.value = "";
    }

</script>

</body>
</html>